<?php
include 'define.php';
include 'mysql_connect.php';

if ($_GET['action']) {
    switch ($_GET['action']) {
        case 'delete_image':
            $img = mysql_value("SELECT `path` FROM `img` WHERE `id`=?", $_POST['id']);
            unlink(ROOT_PATH . $img);
            mysql_delete('img', $_POST['id']);
            break;

        case 'change_news_status':
            $show = mysql_value("SELECT `show` FROM `news` WHERE `id` = ?", $_POST['id']) ? 0 : 1;
            mysql_update('news', array('show' => $show), $_POST['id']);
            break;
        case 'delete_product':
            mysql_delete('product', $_POST['id']);
            break;
        default:
            break;
    }
}